package com.monna.games_2048;

import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.monna.adapter.LeadercoardAdapter;
import com.monna.entity.Score;
import com.monna.util.ScoreUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * 根据数据库存在的用户设置游戏排行榜
 * @author 廖梦青
 */
public class LeadercoardActivity extends AppCompatActivity {

    private ArrayList<Score> heightScoreList = new ArrayList<>();
    private int j =1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_leadercoard);

        heightScoreList = leadercoardScore();
        ListView listView = findViewById(R.id.lv_leaderboard);
        LeadercoardAdapter adapter = new LeadercoardAdapter(heightScoreList, LeadercoardActivity.this);
        listView.setAdapter(adapter);
    }

    /**
     * 获取数据库游戏排行
     * @return
     */
    private ArrayList<Score> leadercoardScore(){
        return new ScoreUtil(this).gamesLeaderboard();
    }
}
